package hu.pixelesztergalyos.continuity;

import java.awt.geom.Point2D;          // http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/geom/Point2D.Float.html
import java.awt.geom.Rectangle2D;      // http://docs.oracle.com/javase/6/docs/api/java/awt/geom/Rectangle2D.Float.html

// Every object in a mosiac will be a MosaicElement
// so the MosaicElement class is the ancestor of these classes
public abstract class MosaicElement {

	private Point2D.Float origin;
	// the coordinate of the MosaicElement, the left top point of the element
	private Rectangle2D.Float boundingBox;
	// a rectangle shaped bounding box to // ease the collisondetection

	// Constructor
	public MosaicElement() {
		this.origin = new Point2D.Float();
		this.boundingBox = new Rectangle2D.Float(this.origin.x, this.origin.y,10, 10);
	}

	// Construct in the given data
	public MosaicElement(float x, float y) {
		this.origin = new Point2D.Float(x, y);
		this.boundingBox = new Rectangle2D.Float(x, y, 10, 10);  // at the given coordinate a 10x10 sized element
	}

	// Returns the coordinate of the MosaicElement
	public Point2D.Float getOrigin() {
		return origin;
	}

	// Returns the bounding box
	public Rectangle2D.Float getBoundingBox() {
		return boundingBox;
	}

	// Sets the origin of the element
	public void setOrigin(Point2D.Float o) {
		origin = o;
		boundingBox.x = origin.x;                // boundingbox.x at element position.x
		boundingBox.y = origin.y;                // boundingbox.y at element position.y
	}

	// Sets the bounding box
	public void setBoundingBox(float w, float h) {
		this.boundingBox = new Rectangle2D.Float(this.origin.x, this.origin.y,
				w, h);
	}

}